import request from '@/utils/request'

export function getCar(data) {
  return request({
    url: '/car',
    method: 'get',
    params: data
  })
}

export function getCarDetail(data) {
  return request({
    url: '/car/' + data,
    method: 'get'
  })
}

export function addCar(data) {
  return request({
    url: '/car',
    method: 'post',
    data
  })
}

export function editCar(data) {
  return request({
    url: '/car/' + data.id,
    method: 'put',
    data
  })
}

export function removeCar(data) {
  return request({
    url: '/car/' + data,
    method: 'delete'
  })
}

// -----------------------------------------

export function getOrder(data) {
  if(data.export){
    return request({
      url: '/order',
      method: 'get',
      params:data,
      responseType:'blob',
    })
  }
  return request({
    url: '/order',
    method: 'get',
    params: data
  })
}
export function getQRCode(data) {
  return request({
    url: '/order/qr_code',
    method: 'get',
    params: data
  })
}

export function getOrderDetail(data) {
  return request({
    url: '/order/' + data,
    method: 'get'
  })
}

export function addOrder(data) {
  return request({
    url: '/order',
    method: 'post',
    data
  })
}

export function editOrder(data) {
  return request({
    url: '/order/' + data.id,
    method: 'put',
    data
  })
}

export function removeOrder(data) {
  return request({
    url: '/order/' + data,
    method: 'delete'
  })
}

export function getBusiness(data) {
  return request({
    url: '/business',
    method: 'get',
    params: data
  })
}

export function getBusinessDetail(data) {
  return request({
    url: '/business/' + data,
    method: 'get'
  })
}

export function addBusiness(data) {
  return request({
    url: '/business',
    method: 'post',
    data
  })
}

export function editBusiness(data) {
  return request({
    url: '/business/' + data.id,
    method: 'put',
    data
  })
}

export function removeBusiness(data) {
  return request({
    url: '/business/' + data,
    method: 'delete'
  })
}

export function getParkRecord(data) {
  if(data.export){
    return request({
      url: '/record_manage',
      method: 'get',
      params:data,
      responseType:'blob',
    })
  }
  return request({
    url: '/record_manage',
    method: 'get',
    params: data
  })
}

export function getParkRecordDetail(data) {
  return request({
    url: '/record_manage/' + data,
    method: 'get',
    params: data
  })
}

export function addParkRecord(data) {
  return request({
    url: '/record_manage',
    method: 'post',
    data
  })
}

export function editParkRecord(data) {
  return request({
    url: '/record_manage/' + data.id,
    method: 'put',
    data
  })
}

export function removeParkRecord(data) {
  return request({
    url: '/record_manage/' + data,
    method: 'delete'
  })
}

export function getLot(data) {
  return request({
    url: '/park_lot',
    method: 'get',
    params:data,
  })
}

export function getLotDetail(data) {
  return request({
    url: '/park_lot/' + data,
    method: 'get'
  })
}

export function addLot(data) {
  return request({
    url: '/park_lot',
    method: 'post',
    data
  })
}

export function editLot(data) {
  return request({
    url: '/park_lot/' + data.id,
    method: 'put',
    data
  })
}

export function removeLot(data) {
  return request({
    url: '/park_lot/' + data,
    method: 'delete',
  })
}
